package it.unicam.cs.cosy.bioshape.core.behaviours.abstraction;

/**
 * @author Federico Buti
 * 
 */
public class AdjTuple implements Comparable<AdjTuple> {
	final String bold;
	ABProcess process;

	AdjTuple(String bond, ABProcess process) {
		this.bold = bond;
		this.process = process;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null)
			return false;
		if (getClass() != o.getClass())
			return false;
		AdjTuple at = (AdjTuple) o;
		if (!bold.equals(at.bold)
				|| !process.name.equals(at.process.name)
				|| process.behaviour.getBehaviour() != at.process.behaviour
						.getBehaviour())
			return false;
		return true;
	}

	@Override
	public int hashCode() {
		final int prime = 92821;
		int result = 1;
		result = prime * result + ((bold == null) ? 0 : bold.hashCode());
		result = prime * result + process.name.hashCode();
		return result;
	}

	@Override
	public int compareTo(AdjTuple adj) {
		int value = bold.compareTo(adj.bold);
		if (value != 0)
			return value;
		//
		value = process.name.compareTo(adj.process.name);
		if (value != 0)
			return value;
		value = process.behaviour.getLabel().compareTo(
				adj.process.behaviour.getLabel());
		if (value != 0)
			return value;
		return 0;
	}
}